package com.yinhe.system.service.impl;

import java.util.List;

import com.yinhe.common.annotation.DataScope;
import com.yinhe.common.utils.DateUtils;
import com.yinhe.system.domain.YhRelationshipTransfer;
import com.yinhe.system.domain.YhSealInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yinhe.system.mapper.YhFeesMapper;
import com.yinhe.system.domain.YhFees;
import com.yinhe.system.service.IYhFeesService;

/**
 * 团费收缴Service业务层处理
 *
 * @author yinhe
 * @date 2022-09-24
 */
@Service
public class YhFeesServiceImpl implements IYhFeesService
{
    @Autowired
    private YhFeesMapper yhFeesMapper;

    /**
     * 查询团费收缴
     *
     * @param id 团费收缴主键
     * @return 团费收缴
     */
    @Override
    public YhFees selectYhFeesById(Long id)
    {
        return yhFeesMapper.selectYhFeesById(id);
    }

    /**
     * 查询团费收缴列表
     *
     * @param yhFees 团费收缴
     * @return 团费收缴
     */
    @Override
    @DataScope(deptAlias = "f", userAlias = "f")
    public List<YhFees> selectYhFeesList(YhFees yhFees)
    {
        return yhFeesMapper.selectYhFeesList(yhFees);
    }

    /**
     * 新增团费收缴
     *
     * @param yhFees 团费收缴
     * @return 结果
     */
    @Override
    public int insertYhFees(YhFees yhFees)
    {
        yhFees.setCreateTime(DateUtils.getNowDate());
        return yhFeesMapper.insertYhFees(yhFees);
    }

    /**
     * 修改团费收缴
     *
     * @param yhFees 团费收缴
     * @return 结果
     */
    @Override
    public int updateYhFees(YhFees yhFees)
    {
        yhFees.setUpdateTime(DateUtils.getNowDate());
        return yhFeesMapper.updateYhFees(yhFees);
    }

    /**
     * 批量删除团费收缴
     *
     * @param ids 需要删除的团费收缴主键
     * @return 结果
     */
    @Override
    public int deleteYhFeesByIds(Long[] ids)
    {
        return yhFeesMapper.deleteYhFeesByIds(ids);
    }

    /**
     * 删除团费收缴信息
     *
     * @param id 团费收缴主键
     * @return 结果
     */
    @Override
    public int deleteYhFeesById(Long id)
    {
        return yhFeesMapper.deleteYhFeesById(id);
    }
    @Override
    public String importFees(List<YhFees> feesList, Boolean isUpdateSupport)
    {
        int successNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();
        for (YhFees fees : feesList) {
            this.insertYhFees(fees);
            successNum++;
            successMsg.append("<br/>" + successNum  + " 导入成功");
            successMsg.insert(0, "恭喜您，数据已全部导入成功！共 " + successNum + " 条，数据如下：");
        }
        return successMsg.toString();
    }
}
